import scrapy


class GitSpider(scrapy.Spider):
    name = 'git'
    allowed_domains = ['github.com']
    start_urls = ['https://github.com/CharlotteChurch']

    def start_requests(self):
        url = self.start_urls[0]

        temp = '_octo=GH1.1.333439395.1640527025; _device_id=296678b69e44f25b9eaeb6fe9c66ccec; user_session=AjkAfNBr1Oa09LN5CnBqIP9XLOSlMUKnO1bxVqxxR0A9Abw2; __Host-user_session_same_site=AjkAfNBr1Oa09LN5CnBqIP9XLOSlMUKnO1bxVqxxR0A9Abw2; logged_in=yes; dotcom_user=CharlotteChurch; has_recent_activity=1; color_mode=%7B%22color_mode%22%3A%22auto%22%2C%22light_theme%22%3A%7B%22name%22%3A%22light%22%2C%22color_mode%22%3A%22light%22%7D%2C%22dark_theme%22%3A%7B%22name%22%3A%22dark_high_contrast%22%2C%22color_mode%22%3A%22dark%22%7D%7D; tz=Asia%2FShanghai; _gh_sess=0ZhgrKVOu90xUnfqp5C%2FCpensPxfAxqvWIUOaa56%2B8S09VFqNc8szeIbw4fIYfKFo%2Bwx5ZpzFHJXyVky8uL3JCVkv1fecK1rjMTDyYUVFATCy0bzsxVXKn9rry6bXQlNC1KY3xpo7Bgo5B7xYFrW8kf2f3Qg1%2BbfI%2FJDtFtWN48ue3RRdy02jUJpLoY6%2Fw4Y--kYGVD91sn83%2B3m2N--ysJh%2BRbJjww8PCVBVAkZlA%3D%3D'
        cookies = {data.split('=')[0]:data.split('=')[-1] for data in temp.split('; ')}

        yield scrapy.Request(
            url=url,
            callback=self.parse,
            cookies=cookies
        )


    def parse(self, response):
        print(response.xpath('//title/text()').extract_first())

